{layout name="passport:layout" /}
<div class="titlebar">
    <svg class="icon fn-f18" aria-hidden="true"><use xlink:href="#icon-wechat"></use></svg> 微信支付
</div>
<div class="tipbox tipbox-message mb5">友情提示：<br />
    <span class="gray">
        1、您的微信支付证书和证书密钥是您的安全凭证,平台承诺不做任何其它用途,但任何应用不是绝对安全,若出现证书被黑客非法使用造成损失的,平台将不承担任何损失,所以请谨慎上传您的支付证书和证书密钥。<br />
        {if $member_miniapp.is_psp == 1}
        2、微信服务商模式下,请配置您的微信服务商商户号。
        {/if}
    </span>
</div>
<div class="tabs">
<ul class="tab_menu">
    <a href="{:url('passport.setting/index')}"><li>关于应用</li></a>
    <a href="{:url('passport.setting/edit')}"><li>应用配置</li></a>
    {if $member_miniapp.miniapp.is_wechat_pay}<a href="{:url('passport.setting/wepay')}"><li class="current">微信支付</li></a>{/if}
    {if $member_miniapp.miniapp.is_alipay_pay}<a href="{:url('passport.setting/alipay')}"><li>支付宝</li></a>{/if}
    <a href="{:url('passport.setting/tplmsg')}"><li>模板消息</li></a>
</ul>
</div>
<form id="form" action="{:url('system/passport.setting/wepay',['id'=>$member_miniapp.id])}">
<input type="hidden" name="id" value="{$member_miniapp.id}" /> 
<table class="formtable"> 
    {if $member_miniapp.is_psp == 1}<tr><th>服务商AppID::</th><td>{$member_miniapp.psp_appid}</td>{/if}
    <tr><th>商户号(mch_id):</th><td><input class="input" datatype="*" type="text" name="mch_id" value="{$config.mch_id}" /> {if $member_miniapp.is_psp == 1}<span class="gray">您的微信服务商商户号</span>{/if}
    </td></tr></tr>
    <tr><th>API密钥:</th><td>
        <input id="key" datatype="alphanum" class="input w300" type="text" name="key" value="{$config.key}" />
        <button type="button" class="create button ">随机生成</button> 
    </td>
    </tr></tr>
    <tr><th>支付证书:</th><td><input id="cert_path" readonly="readonly" class="cert input w300 readonly" type="text" name="cert_path" value="{$config.cert_path}" /></td></tr></tr>
    <tr><th>证书密钥:</th><td><input id="key_path" readonly="readonly" class="cert input w300 readonly" type="text" name="key_path" value="{$config.key_path}" /></td></tr></tr>
    <tr>
        <th></th>
        <td>
            <input type="submit" value="确定" class="button submit" />
            <input type="reset" value="重置" class="button button-blank"/>
        </td>
    </tr>
</table>
</form>
<script type="text/javascript">
Do('base', 'layer', 'form', function () {
    $('#form').isForm();
    $('.cert').click(function(){
        var input = $(this).attr('id');
        var url ='{:url("system/passport.common/cert")}?miniapp_id={$member_miniapp.id}&input='+input;
        parent.layer.open({type: 2,area: ['400','300'],content: url,cancel: function (index, layero) {
            parent.layer.close(index);
        }});
    });
    $('.create').click(function(){
        var key = randomWord(32,32,32)
        $('#key').val(key)
    })
})
</script>